<?php include_once './application/views/sys_admin/common/header.php';  ?>
<!-- admin_main -->
<div class=" definewidth m20">
	<form  method="post" id="consetForm" name="consetForm">
	<input type="hidden" name="id" id="id" value="<?php echo $conset['id']?>"/>
	<input type="hidden" name="bthumbnail" id="bthumbnail" value="<?php echo $conset['thumbnail']?>"/>
		<table class="table table-bordered table-hover m10">
		 <tr>
	        <td class="tableleft">审核资料科目名称</td>
	        <td><input type="text" name="title" id="title" size="50"  value="<?php echo $conset['title']?>"  /> </td>
	   	</tr>
	   	<tr>
	        <td class="tableleft">文件</td>
	        <td>
	        	<div class="mod">
					<ul id="file_att">
						<?php if($conset['thumbnail']){
								$i=0;foreach(unserialize($conset['thumbnail']) as $av){$i++;
							?>
							<li id="att_litpic_<?php echo $i?>">
							<?php 	
								if($av['fileformat'] == 1){
							?>	
							<a target="_blank" href="<?php echo CONSET_SUBJECT_IMG.$av['filename']?>"><img src="<?php echo CONSET_SUBJECT_IMG.$av['filename']?>" width="60" height="60"  /></a>
								<h3><?php echo $conset_subject_file[$av['fileformat']];?></h3>
								<span><a href="javascript:attremove(<?php echo $i;?>);">删除</a></span>
						<?php	
						}else{
							?>
								<h3><?php echo $av['filename'];?></h3>
								<h3><?php echo $conset_subject_file[$av['fileformat']];?></h3>
								<span><a href="javascript:attremove(<?php echo $i;?>);">删除</a></span>
							
							<?php
						}
						?>
						<input type="hidden" name="thumbnailstr[]" value="<?php echo $av['filename'].'|'.$av['fileformat'];?>">
						</li>
						<?php
								}}?>
					</ul>
				</div>						
				<a  href="javascript:;" onclick="add_att();" class="addtr">上传文件</a>
			 </td>
	   	</tr>
	   	<tr>
	        <td class="tableleft">审核资料有效期</td>
	        <td>
	        <select id="valid" name="valid">
				<option value="0">--请选择--</option>
				<?php foreach ($conset_subject_valid as $vk=>$vv){?>
					<option value="<?php echo $vk;?>" <?php if($conset['valid'] == $vk){echo 'selected';}?>><?php echo $vv;?></option>
				<?php }?>
			</select>个月
			</td>
	   	</tr>
	   	 <tr>
	        <td class="tableleft">资料提交说明</td>
	        <td><textarea name="content" id="content" style="width:800px;height:200px;" ><?php echo $conset['content']?></textarea></td>
	   	</tr>
	   	
	   	<tr>
	        <td class="tableleft"></td>
	        <td> <button type="button" class="btn btn-success"  onclick="consetSubmit();" >提交</button> </td>
	   	</tr>
	   </table>
	</form>

</div>
<div id="dialog" title="系统提示" style="display:none"><p id="msg" style="text-align:center"></p>
	<?php include_once './application/views/sys_admin/borrow/borrow_upload.php';  ?>
</div>
<script type="text/javascript">
function add_att(){
	$( "#dialog" ).dialog({
		width:1000,
		height:600,
		modal:false, //蒙层（弹出会影响页面大小）
		title:'上传文件',
		buttons:{"提交":function(){form_submit();},"关闭":function(){$(this).dialog("close");}}
	});
}

var att_arr = [];//定义一个数组
function form_submit(){
	var options = {
		url : '/sys_admin/conset/doupload',
		clearForm :true,
		resetForm :true,
		dataType: "json",
		type:"post",
		contentType:"multipart/form-data",
		success : function(ret) {	
			if(ret.url=='error'){
				alert(ret.msg);
			}else{
				$("#dialog").dialog("close");
				$("#file_att").append(ret.msg.info);
			}
					
			
		}
	};
	$("#upload_form").ajaxSubmit(options);
	return false;
}

function consetSubmit(){
	var options = {
		url : '/sys_admin/conset/edit_subject/',
		dataType: "json",
		type:"post",
		success : function(ret) {
			if(ret.msg=='1'){
				alert("操作成功");
				window.location.href ='/sys_admin/conset/zhs_subject';
			}else{
				alert(ret.msg);
			}
			
		}
	};
	$("#consetForm").ajaxSubmit(options);
	return false;
}

function attremove(id){
	
	$("#att_litpic_"+id).remove();
}
</script>
